package server;

import java.net.*;
import java.io.*;

public class Server 
{

    private SocketManager socketManager = new SocketManager();

    public static void main(String[] args) throws IOException  
    {
        Server server = new Server();
        server.getServer();
    }

    public void getServer() throws IOException
    {
        ServerSocket serverSocket = null;
        boolean listening = true;
        try {
            serverSocket = new ServerSocket(7777);
        } catch (IOException e) {
            System.err.println("Could not listen on port: 7777.");
            System.exit(1);
        }

        while (listening) {
            Socket socket = serverSocket.accept();
            new ServerThread(socket, socketManager).start();
            socketManager.add(socket);
            socketManager.sendClientInfo();
        }

        serverSocket.close();
    }
}

